//tab选项卡--右下
let tbList=document.querySelectorAll(".dt .tb")
let spanList=document.querySelectorAll(".fir span")
function hide(index){
	for(var i=0;i<spanList.length;i++){
		spanList[i].id="";
		tbList[i].id="";
	}
	spanList[index].id="focus"
	tbList[index].id="show";
}
for(var i=0;i<spanList.length;i++){
	spanList[i].setAttribute("sp-list",i);
	spanList[i].onclick=function(){
		index=Number(this.getAttribute("sp-list"))
		hide(index)
	}
}
//左侧导航栏
let liList=$("#box li")
let dpTabList=$("#box li .dp-tab")
function hid(n){
	for(let i=0;i<liList.length;i++){
		liList[i].id=""
		dpTabList[i].id=""
	}
	liList[n].id="in"
	dpTabList[n].id="on"
}
for(let k=0;k<liList.length;k++){
	liList[k].setAttribute("air",k)
	liList[k].onclick=function(){
		n=Number(this.getAttribute("air"))
		hid(n)
		console.log(n)
	}
	liList[k].onmouseenter=function(){
		$(".hide").css({"display":"block"})
	}
	liList[k].onmouseleave=function(){
		$(".hide").css({"display":"none"})
	}
}
//错号
let em=document.querySelector(".down em")
em.onclick=function(){
	this.parentNode.remove()
}
$(".xiazai")
let timer =setTimeout(()=>{
	$(".down").remove()
	clearTimeout(timer)
},2000)
//cookie-------------
let name=document.cookie;
$(".sp2")[0].innerHTML=name.split("=")[1]
//搜索框----------------
let myTimer = null;
document.getElementById("search-content").oninput=function(){
	if(myTimer!=null){
		window.clearTimeout(myTimer);
	}
	//设置计时器
	myTimer = setTimeout(()=>{
		let scriptDom = document.createElement("script");
		scriptDom.src = 'https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=' + this.value + '&json=1&p=3&sid=1438_24869_21080_18560_17001_25177_22160&req=2&bs=1%2B&pbs=1%2B&csor=2&pwd=1%3D&cb=fn&_=1511334117083';
		document.body.appendChild(scriptDom);
		scriptDom.remove();
	},200);
}

function fn(data){
	let arr = data.s;
	let htmlStr = "";
	arr.forEach(item=>{
		htmlStr += `<li>${item}</li>`
	});
	document.getElementById("search-list").innerHTML = htmlStr;
}
//----------------------------
console.log($(".p2")[0])
// ajax2013useobjandpromise({
// 	method: "post",
// 	url: "php/addShoppingCart.php",
// 	params: `goodsId=${($(".goodsId").html()).split(":")[1]}&vipName=${document.cookie.split("=")[1]}&goodsCount=${$(".num").val()}`
	
// }).then(function (data) {
// 	if (data == "1") {
// 		getGoodsInfo()
// 		alert("商品添加成功！")
// 	}
// 	else {
// 		alert("商品添加失败，请重试！")
// 	}
// })